using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using MySql.Data.MySqlClient;
using System.Configuration;


namespace MNNUTEM
{
    public partial class Proveedores : Form
    {
        private crudProveedores Proveedor;
        int idProveedor = 1;

        public Proveedores()
        {
            InitializeComponent();
            Proveedor = new crudProveedores();
        }
        private void button1_Click(object sender, EventArgs e)
        {
            Proveedor.Insert(Rut,Razon,Ingreso,Egreso,Fono,Mail,Direccion);
           
        }

        private void button3_Click(object sender, EventArgs e)
        {
            Proveedor.Delete(idProveedor);
            
        }

        private void updateGridView()
        {
            dataGridView1.DataSource = Proveedor.Consultation("select *from Provedor");

        }


        private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            idProveedor = int.Parse(dataGridView1[0, e.RowIndex].Value.ToString());
            button1.Enabled = false;
            button3.Enabled = true;
            button4.Enabled = true;
            getdatos();
        }

 private void clean()
        {

            Rut.Text = "";
            Razon.Text = "";
            Ingreso.Text = "";
            Egreso.Text = "";
            Fono.Text = "";
            Mail.Text = "";
            Direccion.Text = "";

        }

        private void button2_Click(object sender, EventArgs e)
        {
            clean();
            button3.Enabled = false;
            button4.Enabled = false;
            button1.Enabled = true;
            button2.Enabled = true;
        }

      
    }
}
